﻿using System;

namespace ASPItalia.ModelVirtualCasting.EntityFramework
{
	public class ThreadContextContainer: IContextContainer
	{
		[ThreadStatic]
		private static ModelVirtualCastingEntities _currentContext;

		public ModelVirtualCastingEntities Current
		{
			get { return _currentContext ?? ( _currentContext = new ModelVirtualCastingEntities(Configuration.ConnectionString)); }
		}

		public void Clear()
		{
			_currentContext = new ModelVirtualCastingEntities();
		}
	}
}
